package com.alkalinesolutions.json.core;

/**
 * Indicates the supplied JSON text exceeded a maximum number of nested
 * object/array instances set within the parser. Maximum depths are normally
 * used to prevent certain types of Denial of Sevice attacks.
 * 
 * @author David Waite &lt;<a href='mailto:david@alkaline-solutions.com'>david@alkaline-solutions.com</a>&gt;
 */
public class DepthExceededException extends JSONException {
	private static final long serialVersionUID = 1L;

	private final int depth;
	private final int offset;

	public DepthExceededException(final int p, final int depth) {
		super();
		offset = p;
		this.depth = depth;
	}

	public int getDepth() {
		return depth;
	}

	public int getOffset() {
		return offset;
	}

	@Override
	public String getMessage() {
		return String
				.format(
						Messages.getString("DepthExceededException.message"), new Integer(offset)); //$NON-NLS-1$
	}
}
